package info.macnana.online.core.redis;

import org.springframework.data.redis.core.ListOperations;

import java.util.List;
import java.util.Set;

/**
 * author: zhengheng
 * github: https://github.com/macnana777
 * email: 517862340@qq.com
 * <p>
 * Date: 2017-08-01 14:43
 * Description: redis操作通用类
 * Copyright(©) 2017 by zhengheng.
 */
public interface CommonRedisDao<T> {

    /**
     * 添加
     */
    boolean cacheValue(String key, T value, long time);
    boolean cacheValue(String key, T value);
    /**
     * 是否包含
     */
    boolean containsValueKey(String key);
    boolean containsSetKey(String key);
    boolean containsListKey(String key);
    boolean containsKey(String key);
    /**
     * 获取缓存
     */
    T getValue(String key);
    /**
     * 移除缓存
     */
    boolean removeValue(String key);
    boolean removeSet(String key);
    boolean removeList(String key);
    /**
     * 缓存Set
     */
    boolean cacheSet(String key, T value, long time);
    boolean cacheSet(String key, T value);
    boolean cacheSet(String key, Set<T> value, long time);
    boolean cacheSet(String key, Set<T> value);
    /**
     * 获取Set
     */
    Set<T> getSet(String key);
    /**
     * 缓存List
     */
    boolean cacheList(String key, T value, long time);
    boolean cacheList(String key, T value);
    boolean cacheList(String key, List<T> value, long time);
    boolean cacheList(String key, List<T> value);
    /**
     * 获取List
     */
    List<T> getList(String key, long start, long end);
    /**
     * 获取页码
     */
    long getListSize(String key);
    long getListSize(ListOperations<String, T> listOps, String key);

    /**
     * 移除list缓存
     */
    boolean removeOneOfList(String key);

}


